<?php
include 'PHPModalidadAcademica.php';
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of PHPDaoModalidadAcademica
 *
 * @author user
 */
class PHPDaoModalidadAcademica {
    var $conexion;

    public function __construct() {
        $this->conexion = mysql_connect("localhost","root","");
        mysql_select_db('hoja',$this->conexion);//
    }

    public function ingresar($modalidadAcademica) {
        $consulta = "INSERT INTO modalidadAcademica(codigo,descripcion,abreviacion)
        VALUES($modalidadAcademica->codigo,$modalidadAcademica->descripcion,$modalidadAcademica->abreviacion)";
        $resultado = mysql_query($consulta, $this->conexion) or die(mysql_error());
    }

     public function obtenerTodos() {
        $queEmp         = "SELECT * FROM modalidadAcademica ORDER BY codigo DESC";
        $resultado      = mysql_query($queEmp, $this->conexion) or die(mysql_error());
        $total          = mysql_num_rows($resultado);
        $modalidadAcademica  = array();
        for ($i = 0; $i < $total; $i++) {
            //echo('pase');


            $codigo   = mysql_result($resultado, $i, codigo);
            $descripcion    = mysql_result($resultado, $i, descripcion);
            $abreviacion  = mysql_result($resultado, $i, abreviacion);
            $modalidadAcademica     = new PHPModalidadAcademica($codigo,$descripcion,$abreviacion);
            $modalidadAcademica[]  = $modalidadAcademica;
        }

        return $modalidadAcademica;
    }
}
?>
